﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using YJKRevitKernel.ShortPathSuite;
using YJKGeometryFuncs;

namespace YJKSparseDistance.ModelLayer
{
	public class ResultBean : BaseResultBaen
	{
		public EndPointPacker StartPoint
		{
			get
			{
				return this.m_startPoint;
			}
			protected set
			{
				this.m_startPoint = value;
			}
		}

		public EndPointPacker EndPoint
		{
			get
			{
				return this.m_endPoint;
			}
			protected set
			{
				this.m_endPoint = value;
			}
		}

		public new List<XYZ> LstPoints
		{
			get
			{
				return this.m_lstPoints;
			}
		}

		public new double Distance
		{
			get
			{
				return this.m_dDistance;
			}
			protected set
			{
				this.m_dDistance = value;
			}
		}

		public RulePacker UseRule
		{
			get
			{
				return this.m_useRule;
			}
			set
			{
				this.m_useRule = value;
				if (this.m_useRule != null)
				{
					double num;
					double factoryAndSubValue = this.StartPoint.GetFactoryAndSubValue(out num);
					if (this.StartPoint.IfFinalEnd)
					{
						this.m_dRuleValue = this.m_useRule.ValueForFinalEnd;
					}
					else
					{
						this.m_dRuleValue = this.m_useRule.ValueForNoneFinalEnd;
					}
					this.m_dRuleValue = this.m_dRuleValue * factoryAndSubValue - num;
					if (!Geometry.Lessthan_Or_Equal(this.m_dDistance, this.m_dRuleValue) && !Geometry.Lessthan_Or_Equal(this.m_dRuleValue, 0.0))
					{
						this.m_bIfRight = false;
					}
				}
			}
		}

		public double RuleValue
		{
			get
			{
				return this.m_dRuleValue;
			}
		}

		public bool IfRight
		{
			get
			{
				return this.m_bIfRight;
			}
		}

		public ResultBean(EndPointPacker startPoint, EndPointPacker endPoint, List<XYZ> lstPoints)
		{
			this.m_startPoint = startPoint;
			this.m_endPoint = endPoint;
			this.m_lstPoints = lstPoints;
			this.m_dDistance = BaseResultBaen.CalculateDistance(this.m_lstPoints);
		}

		public override string ToString()
		{
			string empty = string.Empty;
			return string.Concat(new string[]
			{
				this.StartPoint.ToString(),
				":",
				this.EndPoint.ToString(),
				":",
				string.Format("{0:F}", this.Distance)
			});
		}

		private EndPointPacker m_startPoint;

		private EndPointPacker m_endPoint;

		private RulePacker m_useRule;

		private double m_dRuleValue = -1.0;

		private bool m_bIfRight = true;
	}
}
